package com.sc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sc.mapper.ClassMapper;
import com.sc.pojo.Class;
import com.sc.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ClassServiceImpl implements ClassService {
    @Autowired
    ClassMapper mapper;

    public PageInfo<Class> show(Integer pageNum, Integer pageSize, String keyword) {
        PageHelper.startPage(pageNum,pageSize);
        return new PageInfo<>(mapper.query(keyword));
    }

    public int add(Class c) {
        return mapper.insertSelective(c);
    }

    public int del(Integer id) {
        return mapper.deleteByPrimaryKey(id);
    }
    public int upd(Class c) {
        return mapper.updateByPrimaryKeySelective(c);
    }
    public int delAll(Integer[] ids) {
        return mapper.delAllById(ids);
    }

    @Override
    public List<Class> queryAll() {
        return mapper.query(null);
    }

    @Override
    public Class queryById(Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public Class queryByTid(Integer tid) {
        return mapper.selectByTid(tid);
    }
}
